// pagesProperty/pages/oa/contacts/user/index.js

var app = getApp(), fetchApi = require("../../../../../utils/httpPost.js")
, common_Js = require("../../../../../component/common.js");
import Dialog from '../../../../../component/vant/dialog/dialog';
import Toast from '../../../../../component/vant/toast/toast';
Page({

  /**
   * 页面的初始数据
   */
  data: {
    estateUsers:[],
    isLoading:true,
    dept_id:0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    if(options.dept_id){
      this.data.dept_id = options.dept_id
    }
    this.onHttpInit();
  },

  onHttpInit: function () {
    var that = this;
    fetchApi.httpPost("/estate/user/list", {
      dept_id: that.data.dept_id,
    }, function (res) {
      console.log("获取通讯录返回数据:", res)
      that.setData({
        estateUsers: res.data.data.estateUsers,
        isLoading:false,
      });

    }, function (a) {
      console.log("获取通讯录返回数据 err:", a);
    });
  },
  makePhone(e){
    var item = e.currentTarget.dataset.item;
    var message = '是否要与' + item.nickName + '通话？';
    Dialog.confirm({
      title: '温馨提示',
      message,
      showConfirmButton:true,
      confirmButtonText:'联系Ta',
    }).then(() => {
      wx.makePhoneCall({
        phoneNumber: item.phoneNum,
      })
    })
    .catch(() => {
      Dialog.close();
    });
    
  }
})